#include "range.cpp"
class ValueInRange {
private:
	float x;
	Range* range;

	
	 

public:

	ValueInRange(float x, Range* range) {
		
		this->x = x;
		setRange(range);
	}
	
	bool isCorrupted(){
		return range->rangeCheck(x);
	}
	float getX() {
		return x;
	}

	bool setX(float x) {
		if(range==NULL)
			return false;
		if(range->rangeCheck(x)){
			this->x = x;	
			return true;
		}
		return false;
	}

	bool setRange(Range* r){
		if(r->rangeCheck(x)){
			if(this->range != NULL)
				this->range->lockDown();
			r->lockUp();
			this->range=r;
			return true;
		}
		return false;
	}
};

/*
  int main(){
 
 Range* range = new Range(1,4);
 ValueInRange val (6, range);
 
 printf("Intervallo %d   %d \n",  range->getA() , range->getB());
 
 
 
 return 0; }

*/
